﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using ClassLibrary.Configuration.Switch;

namespace SwitchingConfigGenerator
{
    class Program
    {
        static void Main(string[] args)
        {
            const String outputPath = @"c://SwitchConfiguration.xml";

            var switchingTable = new ConfSwitchingTable()
                {
                    Records = new ConfSwitchingTable.Record[]
                        {
                            new ConfSwitchingTable.Record()
                                {
                                    Ingress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 0, VcId = 0},
                                    Egress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 1, VcId = 1}
                                },
                            new ConfSwitchingTable.Record()
                                {
                                    Ingress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 0, VcId = 1},
                                    Egress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 0, VcId = 0}
                                },
                            new ConfSwitchingTable.Record()
                                {
                                    Ingress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 0, VcId = 2},
                                    Egress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 2, VcId = 2}
                                },
                            new ConfSwitchingTable.Record()
                                {
                                    Ingress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 1, VcId = 0},
                                    Egress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 0, VcId = 2}
                                },
                            new ConfSwitchingTable.Record()
                                {
                                    Ingress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 1, VcId = 1},
                                    Egress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 2, VcId = 1}
                                },
                            new ConfSwitchingTable.Record()
                                {
                                    Ingress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 1, VcId = 2},
                                    Egress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 0, VcId = 1}
                                },
                            new ConfSwitchingTable.Record()
                                {
                                    Ingress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 2, VcId = 0},
                                    Egress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 1, VcId = 0}
                                },
                            new ConfSwitchingTable.Record()
                                {
                                    Ingress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 2, VcId = 1},
                                    Egress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 2, VcId = 0}
                                },
                            new ConfSwitchingTable.Record()
                                {
                                    Ingress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 2, VcId = 2},
                                    Egress = new ConfSwitchingTable.Record.SwitchingPair() {PortId = 1, VcId = 2}
                                }

                        }
                };

            var random = new Random();

            var nRecords = 10;
            var nPorts = 10;
            var nVc = 2;

            var switchConfiguration = new SwitchConfiguration() { Id = "A", ConfSwitchingTable = switchingTable, LogicalPortsNo = 3, MultiplexerInfos = new MultiplexerInfo[] { new MultiplexerInfo() { EgressLogicalPortId = 2, FirstIngressPhysicalPortId = 2, IngressPortsNo = 3 } }, PhysicalPortsNo = 5, WireCloudIp = "127.0.0.1", WireCloudPort = 9050 };

            var writer = new XmlSerializer(typeof(SwitchConfiguration));
            using (var file = File.Create(outputPath))
            {
                writer.Serialize(file, switchConfiguration);
            }

        }
    }
}
